<?php
/**
 * 后台发送重置密码邮箱
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/5/28 14:52
 * @copyright PanxSoft Inc.
 */

namespace App\Services\Mailer\Admin;

use Carbon\Carbon;
use Illuminate\Mail\Mailer;
use Illuminate\Mail\Message;

class PasswordResetMail
{
    const RESET_PASSWORD_VIEW = 'email.admin-reset-password';

    /**
     * @test
     *
     * @param string $email
     * @param string $reset_url
     */
    public static function send(string $email, string $reset_url): void
    {
        /** @var Mailer $mailer */
        $mailer = app('mailer');

        $mailer->send(self::RESET_PASSWORD_VIEW, compact('reset_url'),
            function (Message $msg) use ($email) {
                $msg->subject(trans('service.subject') . Carbon::now());
                /**
                 * 此处 from address 如果使用 qq 邮箱必须与 .env 中 MAIL_USERNAME 一致
                 */
                $msg->from(config('mail.username'), 'Beauty Mirror Reset Password');
                $msg->to($email);
            });
    }
}